#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <pwd.h>

int main()
{
	struct passwd *test;
	char username[20];
	char net;

	strcpy(username, "listar");

	//strcpy(username, "ftp");
	if ((test = getpwnam(username)) == NULL) {
		printf("getpwnam: %s\n", strerror(errno));	
		return (-1);
	}
	/*if (setuid(test->pw_uid) == -1) {*/
		/*printf("setuid:%s\n", strerror(errno));	*/
		/*return (-1);*/
	/*}*/
	
	printf("process uid = %d\n", getuid());
	printf("process gid = %d\n", getgid());
	if (setgid(test->pw_gid) == -1) {
		printf("setgid:%s\n", strerror(errno));	
		return (-1);
	}

	printf("uid = %d\n", getuid());
	printf("gid = %d\n", getgid());

	return 0;
}
